#ifndef PARSER_H
#define PARSER_H

#include "log_elem.h"

typedef struct LogParser {
    FILE *log_file;
    void *opaque;
    int (*parse) (void * opaque, FILE* f, LogElem *le);
    int (*destruct) (void * opaque);
} LogParser;

/* 解析Log并填充LogElem  终止：0，读入：1，错误-1 */

#define PARSE_LOG_ERR -1
#define PARSE_LOG_INCOMING 1
#define PARSE_LOG_END 0

static inline int parse_log (LogParser *p, LogElem *le) {
    return p->parse(p->opaque, p->log_file, le);
}

int sandbox_log_parser_create (LogParser **p, FILE *f);

int winprocmon_log_parser_create (LogParser **p, FILE *f);

#endif